package com.yty.demo._6_collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @author: yangtaoyao
 * @time: 2020/1/13 14:44
 * @description:
 */
public class CollectionsTest {
    public static void main(String[] args) {
        List<String> l=new ArrayList<>();
        l.add("a");
        l.add("12");
        l.add("1s");

        Collections.reverse(l);
        System.out.println(l);
        Collections.sort(l);//根据元素的自然顺序按升序排序
        Collections.shuffle(l);//随机排序
        Collections.sort(l, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return 0;
            }
        });//根据Comparator产生的顺序进行排序；
        Collections.swap(l,0,1);//对集合中的i处元素和j处元素进行交换；
        Collections.max(l);
        Collections.max(l, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return 0;
            }
        });
        Collections.min(l);
        Collections.frequency(l,"a");
        Collections.replaceAll(l,"a","b");
        System.out.println(l);
    }
}
